<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改商品')" />
    <th:block th:include="include :: summernote-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-product-edit" th:object="${goodsProduct}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">商品组id：</label>
                <div class="col-sm-8">
                    <input name="groupId" th:field="*{groupId}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">标题：</label>
                <div class="col-sm-8">
                    <input name="title" th:field="*{title}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">规格明细逗号拼接：</label>
                <div class="col-sm-8">
                    <input name="resumeStr" th:field="*{resumeStr}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">商品编码：</label>
                <div class="col-sm-8">
                    <input name="sku" th:field="*{sku}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">主数据sku 名称：</label>
                <div class="col-sm-8">
                    <input name="skuName" th:field="*{skuName}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">商品单位：</label>
                <div class="col-sm-8">
                    <input name="unit" th:field="*{unit}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">列表图：</label>
                <div class="col-sm-8">
                    <input name="listImg" th:field="*{listImg}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">商品banner：</label>
                <div class="col-sm-8">
                    <input name="banner" th:field="*{banner}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">相册：</label>
                <div class="col-sm-8">
                    <textarea name="detailImg" class="form-control">[[*{detailImg}]]</textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">分享海报图：</label>
                <div class="col-sm-8">
                    <input name="sharePoster" th:field="*{sharePoster}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">商品属性(json)：</label>
                <div class="col-sm-8">
                    <textarea name="goodsAttr" class="form-control">[[*{goodsAttr}]]</textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">商品标签英文空格拆分：</label>
                <div class="col-sm-8">
                    <input name="tags" th:field="*{tags}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">内容：</label>
                <div class="col-sm-8">
                    <input type="hidden" class="form-control" th:field="*{content}">
                    <div class="summernote" id="content"></div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">描述：</label>
                <div class="col-sm-8">
                    <input name="description" th:field="*{description}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">分类：</label>
                <div class="col-sm-8">
                    <input name="categoryId" th:field="*{categoryId}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">售价：</label>
                <div class="col-sm-8">
                    <input name="price" th:field="*{price}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">原价：</label>
                <div class="col-sm-8">
                    <input name="originalPrice" th:field="*{originalPrice}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">排序：</label>
                <div class="col-sm-8">
                    <input name="sortOrder" th:field="*{sortOrder}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">是否在售 1-正常 0-下架：</label>
                <div class="col-sm-8">
                    <input name="isSale" th:field="*{isSale}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">库存：</label>
                <div class="col-sm-8">
                    <input name="inventory" th:field="*{inventory}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">商品活动图标：</label>
                <div class="col-sm-8">
                    <textarea name="discountInfoIcon" class="form-control">[[*{discountInfoIcon}]]</textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">上架时间：</label>
                <div class="col-sm-8">
                    <input name="upTime" th:field="*{upTime}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">下架时间：</label>
                <div class="col-sm-8">
                    <input name="downTime" th:field="*{downTime}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">是否用于推荐:0否,1是：</label>
                <div class="col-sm-8">
                    <input name="isRecommend" th:field="*{isRecommend}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">供应商id：</label>
                <div class="col-sm-8">
                    <input name="supplierId" th:field="*{supplierId}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">板块id,多个逗号隔开：</label>
                <div class="col-sm-8">
                    <input name="plateId" th:field="*{plateId}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">选择门店拓展字段：</label>
                <div class="col-sm-8">
                    <textarea name="goodsStoreStr" class="form-control">[[*{goodsStoreStr}]]</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">选择门店城市列表：</label>
                <div class="col-sm-8">
                    <textarea name="cityCodeListStr" class="form-control">[[*{cityCodeListStr}]]</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">选择门店列表：</label>
                <div class="col-sm-8">
                    <textarea name="storeCodeListStr" class="form-control">[[*{storeCodeListStr}]]</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">选择门店城市列表：</label>
                <div class="col-sm-8">
                    <textarea name="notInCityCodeListStr" class="form-control">[[*{notInCityCodeListStr}]]</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">选择门店列表：</label>
                <div class="col-sm-8">
                    <textarea name="notInStoreCodeListStr" class="form-control">[[*{notInStoreCodeListStr}]]</textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">订单回调扩展参数：</label>
                <div class="col-sm-8">
                    <input name="orderExtend" th:field="*{orderExtend}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">购买次数限制：</label>
                <div class="col-sm-8">
                    <input name="buyNumLimit" th:field="*{buyNumLimit}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">是否有赠品 0 否 1是：</label>
                <div class="col-sm-8">
                    <input name="hasGift" th:field="*{hasGift}" class="form-control" type="text" required>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: summernote-js" />
    <script th:inline="javascript">
        var prefix = ctx + "mall/product";
        $("#form-product-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-product-edit').serialize());
            }
        }

        $(function() {
            $('.summernote').each(function(i) {
                $('#' + this.id).summernote({
                    lang: 'zh-CN',
                    dialogsInBody: true,
                    callbacks: {
                        onChange: function(contents, $edittable) {
                            $("input[name='" + this.id + "']").val(contents);
                        },
                        onImageUpload: function(files) {
                            var obj = this;
                            var data = new FormData();
                            data.append("file", files[0]);
                            $.ajax({
                                type: "post",
                                url: ctx + "common/upload",
                                data: data,
                                cache: false,
                                contentType: false,
                                processData: false,
                                dataType: 'json',
                                success: function(result) {
                                    if (result.code == web_status.SUCCESS) {
                                        $('#' + obj.id).summernote('insertImage', result.url);
                                    } else {
                                        $.modal.alertError(result.msg);
                                    }
                                },
                                error: function(error) {
                                    $.modal.alertWarning("图片上传失败。");
                                }
                            });
                        }
                    }
                });
                var content = $("input[name='" + this.id + "']").val();
                $('#' + this.id).summernote('code', content);
            })
        });
    </script>
</body>
</html>